/**
 * 
 */
package offer.algorithm;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @author zhang 数组中只有两个数出现了一次，其余的都出现了两次，找出来
 */
public class AppearOnce40 {

	public static void FindNumsAppearOnce(int[] array, int num1[], int num2[]) {
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < array.length; i++) {
			if (set.contains(array[i])) {
				set.remove(array[i]);
			} else {
				set.add(array[i]);
			}
		}
		Iterator<Integer> iterator = set.iterator();
		while (iterator.hasNext()) {
			num1[0] = iterator.next();
			num2[0] = iterator.next();
		}
	}

	public static void main(String[] args) {
		int[] arr = { 1, 5, 4, 7, 2, 5, 7, 4 };
		// FindNumsAppearOnce(arr);
	}

}
